<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
      
    
    
      
    
  <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
  <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css">







  

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="css,">





  <link rel="alternate" href="/atom.xml" title="TiX" type="application/atom+xml">






<meta name="description" content="记录在阮一峰博客看到的实用方法。">
<meta name="keywords" content="css">
<meta property="og:type" content="article">
<meta property="og:title" content="简单常用的flex">
<meta property="og:url" content="https://gitee.com/L1334101793/简单常用的flex/index.html">
<meta property="og:site_name" content="TiX">
<meta property="og:description" content="记录在阮一峰博客看到的实用方法。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-05-24T02:47:51.922Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="简单常用的flex">
<meta name="twitter:description" content="记录在阮一峰博客看到的实用方法。">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"right","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/L1334101793/简单常用的flex/">





  <title>简单常用的flex | TiX</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-right page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">TiX</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Stay Hungry, Stay Foolish</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/L1334101793/简单常用的flex/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="TiX">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="TiX">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">简单常用的flex</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-24T09:54:39+08:00">
                2019-05-24
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/css/" itemprop="url" rel="index">
                    <span itemprop="name">css</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o">本文阅读</i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>人次
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>记录在阮一峰博客看到的实用方法。<br><a id="more"></a></p>
<h3 id="flex-direction属性（父用）决定主轴的方向（即项目的排列方向）。"><a href="#flex-direction属性（父用）决定主轴的方向（即项目的排列方向）。" class="headerlink" title="flex-direction属性（父用）决定主轴的方向（即项目的排列方向）。"></a>flex-direction属性（父用）决定主轴的方向（即项目的排列方向）。</h3><p>有4个值：<br>  row（默认值）：主轴为水平方向，起点在左端。<br>  row-reverse：主轴为水平方向，起点在右端。<br>  column：主轴为垂直方向，起点在上沿。<br>  column-reverse：主轴为垂直方向，起点在下沿。</p>
<h3 id="flex-wrap属性（父用）"><a href="#flex-wrap属性（父用）" class="headerlink" title="flex-wrap属性（父用）"></a>flex-wrap属性（父用）</h3><p>有3个值：<br>  nowrap（默认）：不换行。<br>  wrap：换行，第一行在上方。<br>  wrap-reverse：换行，第一行在下方。</p>
<h3 id="flex-flow（父用）"><a href="#flex-flow（父用）" class="headerlink" title="flex-flow（父用）"></a>flex-flow（父用）</h3><p>flex-flow属性是flex-direction属性和flex-wrap属性的简写形式，默认值为row nowrap。</p>
<h3 id="justify-content属性（父用）"><a href="#justify-content属性（父用）" class="headerlink" title="justify-content属性（父用）"></a>justify-content属性（父用）</h3><p>justify-content属性定义了项目在主轴上的对齐方式。<br>有5个值：<br>  flex-start（默认值）：左对齐。<br>  flex-end：右对齐。<br>  center： 居中。<br>  space-between：两端对齐，项目之间的间隔都相等。<br>  space-around：每个项目两侧的间隔相等。所以，项目之间的间隔比项目与边框的间隔大一倍。</p>
<h3 id="align-items属性（父用）"><a href="#align-items属性（父用）" class="headerlink" title="align-items属性（父用）"></a>align-items属性（父用）</h3><p>align-items属性定义项目在交叉轴上如何对齐（就是在高度上怎么对齐）。<br>  flex-start：交叉轴的起点对齐。<br>  flex-end：交叉轴的终点对齐。<br>  center：交叉轴的中点对齐。<br>  baseline: 项目的第一行文字的基线对齐。<br>  stretch（默认值）：如果项目未设置高度或设为auto，将占满整个容器的高度。</p>
<h3 id="align-content属性（父用）"><a href="#align-content属性（父用）" class="headerlink" title="align-content属性（父用）"></a>align-content属性（父用）</h3><p>align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线，该属性不起作用。<br>  flex-start：与交叉轴的起点对齐。<br>  flex-end：与交叉轴的终点对齐。<br>  center：与交叉轴的中点对齐。<br>  space-between：与交叉轴两端对齐，轴线之间的间隔平均分布。<br>  space-around：每根轴线两侧的间隔都相等。所以，轴线之间的间隔比轴线与边框的间隔大一倍。<br>  stretch（默认值）：轴线占满整个交叉轴。</p>
<h3 id="order属性（子用）"><a href="#order属性（子用）" class="headerlink" title="order属性（子用）"></a>order属性（子用）</h3><p>order属性定义项目的排列顺序。数值越小，排列越靠前，默认为0。</p>
<h3 id="flex-shrink属性（子用）"><a href="#flex-shrink属性（子用）" class="headerlink" title="flex-shrink属性（子用）"></a>flex-shrink属性（子用）</h3><p>flex-shrink属性定义了项目的缩小比例，默认为1，即如果空间不足，该项目将缩小。</p>
<h3 id="flex属性（子用）和flex-grow-属性（子用）"><a href="#flex属性（子用）和flex-grow-属性（子用）" class="headerlink" title="flex属性（子用）和flex-grow 属性（子用）"></a>flex属性（子用）和flex-grow 属性（子用）</h3><p>flex：<br>（1）弹性布局默认不改变项目的宽度，但是会改变它的高度，如果项目没有显式指定高度，就将占据容器的所有高度。<br>（2）弹性布局默认左对齐，一般会从行首开始排列。<br>flex属性是flex-grow, flex-shrink 和 flex-basis的简写，默认值为0 1 auto。后两个属性可选。<br>建议优先使用这个属性，而不是单独写三个分离的属性，因为浏览器会推算相关值。</p>
<p>flex-grow：<br>  属性默认等于0，即使用本来的宽度，不拉伸。等于1时，就表示该项目宽度拉伸，占据当前行的所有剩余宽度。</p>
<h3 id="align-self-属性（子用）和-align-items-属性（父用）"><a href="#align-self-属性（子用）和-align-items-属性（父用）" class="headerlink" title="align-self 属性（子用）和 align-items 属性（父用）"></a>align-self 属性（子用）和 align-items 属性（父用）</h3><p>align-self：<br>  flex-start：顶边对齐，高度不拉伸<br>  flex-end：底边对齐，高度不拉伸<br>  center：居中，高度不拉伸<br>  stretch：默认值，高度自动拉伸<br>如果项目很多，一个个地设置align-self属性就很麻烦。这时，可以在容器元素设置align-items属性，它的值被所有子项目的align-self属性继承。<br>为容器元素设置了align-items以后，就不用在控件上设置align-self，除非希望两者的值不一样。</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div></div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wcpay.png" alt="TiX 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.png" alt="TiX 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/css/" rel="tag"># css</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/vue中双击按钮出现多次提交情况解决方法/" rel="next" title="vue中双击按钮出现多次提交情况解决方法">
                <i class="fa fa-chevron-left"></i> vue中双击按钮出现多次提交情况解决方法
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/node学习历程一/" rel="prev" title="node学习历程一">
                node学习历程一 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">TiX</p>
              <p class="site-description motion-element" itemprop="description">个人学习记录，涉及前端，分享心得等。</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">21</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#flex-direction属性（父用）决定主轴的方向（即项目的排列方向）。"><span class="nav-number">1.</span> <span class="nav-text">flex-direction属性（父用）决定主轴的方向（即项目的排列方向）。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flex-wrap属性（父用）"><span class="nav-number">2.</span> <span class="nav-text">flex-wrap属性（父用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flex-flow（父用）"><span class="nav-number">3.</span> <span class="nav-text">flex-flow（父用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#justify-content属性（父用）"><span class="nav-number">4.</span> <span class="nav-text">justify-content属性（父用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#align-items属性（父用）"><span class="nav-number">5.</span> <span class="nav-text">align-items属性（父用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#align-content属性（父用）"><span class="nav-number">6.</span> <span class="nav-text">align-content属性（父用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#order属性（子用）"><span class="nav-number">7.</span> <span class="nav-text">order属性（子用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flex-shrink属性（子用）"><span class="nav-number">8.</span> <span class="nav-text">flex-shrink属性（子用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#flex属性（子用）和flex-grow-属性（子用）"><span class="nav-number">9.</span> <span class="nav-text">flex属性（子用）和flex-grow 属性（子用）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#align-self-属性（子用）和-align-items-属性（父用）"><span class="nav-number">10.</span> <span class="nav-text">align-self 属性（子用）和 align-items 属性（父用）</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2019 &mdash; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">TiX</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Mist</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">访客</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">总访问</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      人次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
  

  
  
    <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
